package cn.tedu.hospital.admin.server.user.controller;

import cn.tedu.hospital.admin.server.common.web.JsonResult;
import cn.tedu.hospital.admin.server.user.pojo.param.UserAddNewParam;
import cn.tedu.hospital.admin.server.user.service.IUserService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 处理用户相关请求的控制类
 *
 * @author qiqiang@deng
 * @version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/account/users")
@Validated
@Api(tags = "1.1. 账号管理-用户管理")
public class UserRegController {

    @Autowired
    private IUserService userService;

    public UserRegController(){
        log.info("创建控制器对象：UserController");
    }

    @PostMapping("/add-new")
    @ApiOperation("添加用户")
    @ApiOperationSupport(order = 100)
    public JsonResult addNew(@Valid UserAddNewParam userAddNewParam){
        log.debug("开始处理【添加用户】的请求，参数{}", userAddNewParam);
        userService.addNew(userAddNewParam);
        return JsonResult.ok();
    }
}
